﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace NathansMapInfoProjects.WindowManager.Views
{
    /// <summary>
    /// Interaction logic for WindowView.xaml
    /// </summary>
    public partial class WindowView : UserControl
    {
        public WindowView()
        {
            InitializeComponent();
        }

        /// <summary>
        /// This selects all the text and pushes focus to the TextBox when it 
        /// is shown.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTextBoxVisible(object sender, SizeChangedEventArgs e)
        {
            
        }

        private void etb_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            TextBox tb = (TextBox)sender;
            if (tb.IsLoaded && tb.Visibility == System.Windows.Visibility.Visible &&
                FocusManager.GetFocusedElement(this) != tb)
            {
                tb.Focus();
                tb.SelectAll();
            }
        }
    }
}
